import GameView from "../../../../quick/core/ui/GameView";
import { inject } from "../../../../quick/defines/Decorators";

const {ccclass, property} = cc._decorator;

@ccclass
export default class SnapshotView extends GameView {
    public static getPrefabUrl(): string {
        return "prefabs/SnapshotView";
    }

    @inject("girl",cc.Node)
    private girl : cc.Node = null!;
    @inject("show",cc.Sprite)
    private showSprite : cc.Sprite = null!;

    onLoad(): void {
        super.onLoad();
        this.onN(cc.find("goback",this.node),cc.Node.EventType.TOUCH_END,this.backBundle);
        this.onN(cc.find("capture",this.node),cc.Node.EventType.TOUCH_END,this.onCapture);
    }

    private onCapture(){
        App.platform.snapshot(this.girl,(sp,size)=>{
            if ( sp ){
                this.showSprite.spriteFrame = sp;
                this.showSprite.node.setContentSize(size);
            }
        })
    }
}
